{% extends 'mould/index.html' %}

{% block title %}
  registered
{% endblock %}

{% block body %}
  <div class="container mar-bot">
    <div class="re-box-out">
      <div class="re-box-in">
        <div class="page-header">
          <h3>参与抢注-填写表单
            <small style="font-size: 20px; color: #1a840f;">
              <a href="/detail-{{ id }}.html" class="url">{{ domain_name }}</a>
            </small>
          </h3>
        </div>
        <p class="re-prompt">注：请正确填写表单，以便抢注成功后管理员可以快速联系到您！</p>
        <div class="re-form-top">
          <p class="re-form-top-p">当前域名抢注人数: <span>{{ totle }}</span></p>
          <p class="re-form-top-p">当前域名抢注的最高价格为: <span><span style="color: red;">￥</span>{{ max_price }}</span>
          </p>
        </div>
        <div class="re-form">
          <form id='form' action="/registered" method="POST">

            <div class="form-group">
              <label for="domain_name">域名</label>
              <input type="text" class="form-control" id="domain_name" disabled="disabled"
                     placeholder="{{ domain_name }}"/>
              <input type="text" style="display: none;" name="domainName" value="{{ domain_name }}"/>
            </div>
            <div class="form-group">
              <label for="email"><span style="color: red;">*</span>邮箱</label>
              <input type="email" class="form-control" id="email" name="email" placeholder="请输入邮箱账号">
            </div>
            <div class="form-group">
              <label for="tel"><span style="color: red;">*</span>手机号</label>
              <input type="tel" class="form-control" id="tel" name="tel" placeholder="请输入通讯手机号">
            </div>
            <div class="form-group">
              <label for="wechat">微信号</label>
              <input type="text" class="form-control" id="wechat" name="wechat" placeholder="请输入微信号">
            </div>
            <div class="form-group">
              <label for="price"><span style="color: red;">*</span>竞拍价格</label>
              <div class="input-group">
                <div class="input-group-addon">$</div>
                <input type="text" class="form-control" id="price" name="price" placeholder="请输入竞拍价格">
              </div>
            </div>
            <input type="submit" class="btn btn-primary" value="提交竞拍信息"/>
          </form>
        </div>
      </div>
    </div>
  </div>
  <script src="/static/js/jquery.min.js"></script>
  <script>
      $(document).ready(function () {
          $('#form').removeAttr('action');
      });

      function checkNumber(theObj) {
          var reg = /^[0-9]+.?[0-9]*$/;
          if (reg.test(theObj)) {
              return true;
          };
          return false;
      };

      $('#price').change(function () {
          if ($('#email').val() != '' && $('#tel').val() !=
              '' && $('#price').val() != '') {
              if (checkNumber(parseInt($('#price').val()))) {
                  $('#form').attr('action', '/registered');
              } else {
                  $('#form').removeAttr('action');
                  window.alert('请输入正确的价格');
              }
              ;
          } else {
              $('#form').removeAttr('action');
              window.alert('请输入正确的邮箱、手机号和竞价价格（微信号选填）！');
          }
          ;

      });

  </script>
{% endblock %}